package com.aotain.common;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Properties;

import org.apache.log4j.Logger;

public class SystemConfig {
	
	private String _ips = "";
	private int _hbaseImportThreadNum = 20;
	private int _hbaseImportCommitNum = 20000;
	

	public SystemConfig(String configFile)
	{
		System.out.println("dbconfig:" + configFile);
	    
	    try {   
	    	Properties prop = new Properties();   
		    InputStream in = new FileInputStream(configFile);
	        prop.load(in);   
	        
	        
	        _ips = prop.getProperty("ips"); 
	        
//	        String hbaseImportThreadNum = prop.getProperty("hbase.import.threadnum");
//	        if(hbaseImportThreadNum != null && hbaseImportThreadNum != "")
//	        {
//	        	_hbaseImportThreadNum = Integer.parseInt(hbaseImportThreadNum);
//	        }
//	        
//	        String hbaseImportCommitNum = prop.getProperty("hbase.import.commitnum");
//	        if(hbaseImportCommitNum != null && hbaseImportCommitNum != "")
//	        {
//	        	_hbaseImportCommitNum = Integer.parseInt(hbaseImportCommitNum);
//	        }
	        
	        _ips = prop.getProperty("ips").trim(); 
	        
	        
	        
	    } catch (IOException e) {   
	        e.printStackTrace();   
	    }   
	}
	
	public HashMap<String,String> CheckIPs()
	{
		HashMap<String,String> map = new HashMap<String,String>();
		
		String ips = _ips;
		Logger.getRootLogger().info(ips);
		
		String[] items = ips.split(",",-1);
		for(String ip:items)
		{
			map.put(ip, ip);
		}
		
		return map;
	}
	
	public String IPs()
	{
		return _ips;
	}
	
	
	public int getHbaseImportThreadNum()
	{
		return _hbaseImportThreadNum;
	}
	
	public int getHbaseImportCommitNum()
	{
		return _hbaseImportCommitNum;
	}
}
